package edu.udlap.spring2008.is300.finalexam.framework.mvc.observerobservable.favorites;

import java.util.ArrayList;
import java.util.Iterator;

/**
 *
 * @author Ruslán Ledesma Garza
 */
public class FavoritesChangedObservableHelper implements FavoritesChangedObservable
{

    ArrayList<FavoritesChangedListener> observers = new ArrayList<FavoritesChangedListener>();
    FavoritesChangedObservable observedObject;
    
    public FavoritesChangedObservableHelper(FavoritesChangedObservable observedObject)
    {
        this.observedObject = observedObject;
    }
    
    public void addFavoritesChangedListener(FavoritesChangedListener observer)
    {
        observers.add(observer);
    }

    public void removeFavoritesChangedListener(FavoritesChangedListener observer)
    {
        observers.remove(observer);
    }

    public void raiseFavoritesChangedEvent(Object args)
    {
        Iterator<FavoritesChangedListener> i = observers.iterator();
        FavoritesChangedListener observer;
        while(i.hasNext())
        {
            observer = i.next();
            observer.favoritesChanged(observedObject, args);
        }
    }

}
